package com.bw.liuyushan.liuyushan20210904.MVP.Fragment;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.bw.liuyushan.liuyushan20210904.Adapter.TableFragmentAdapter;
import com.bw.liuyushan.liuyushan20210904.MVP.Contrack.IContrackTest;
import com.bw.liuyushan.liuyushan20210904.MVP.Model.BaseModelTest;
import com.bw.liuyushan.liuyushan20210904.MVP.Presenter.BasePresenterTest;
import com.bw.liuyushan.liuyushan20210904.R;
import com.bw.liuyushan.mvp_lib.VIew.BaseFragment;
import com.google.android.material.tabs.TabLayout;

import java.util.ArrayList;

/**
 * Liuyushan20210904
 * file name is : Fragment1
 * created by Ender on 2021/9/4 8:25.
 * author : 刘雨杉
 * Describe:
 */
public class Fragment1 extends BaseFragment<BasePresenterTest> implements IContrackTest.C_ViewTest {
    private TabLayout tabFragment1;
    private ViewPager vpFragment1;
    ArrayList<Fragment> fragments;
    ArrayList<String> strings;

    @Override
    public int bindLayout() {
        return R.layout.fragment_1;
    }

    @Override
    public void initView() {
        //防止内存泄露
        mPresenter = new BasePresenterTest(new BaseModelTest(), this);

        tabFragment1 = (TabLayout) findViewById(R.id.tab_fragment1);
        vpFragment1 = (ViewPager) findViewById(R.id.vp_Fragment1);
    }

    @Override
    public void initDate() {

        fragments = new ArrayList<>();
        fragments.add(new FragmentTab2());
        fragments.add(new FragmentTab1());
        fragments.add(new FragmentTab3());

        strings = new ArrayList<>();
        strings.add("关注");
        strings.add("推荐");
        strings.add("视频");
        TableFragmentAdapter tableFragmentAdapter = new TableFragmentAdapter(getChildFragmentManager(), fragments, strings);
        vpFragment1.setAdapter(tableFragmentAdapter);
        tabFragment1.setupWithViewPager(vpFragment1);
        vpFragment1.setCurrentItem(1);


    }
}
